package cn.iocoder.yudao.module.member.controller.admin.order;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
import cn.iocoder.yudao.module.member.controller.admin.order.vo.AdminOrderPageVo;
import cn.iocoder.yudao.module.member.controller.admin.order.vo.AdminOrderVo;
import cn.iocoder.yudao.module.member.controller.app.order.vo.AppOrderPageVo;
import cn.iocoder.yudao.module.member.controller.app.order.vo.AppOrderVo;
import cn.iocoder.yudao.module.member.dal.dataobject.order.MemberOrderDo;
import cn.iocoder.yudao.module.member.service.order.OrderService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;

@Tag(name = "后台 - 订单管理")
@RestController
@RequestMapping("/member/order")
@Validated
public class AdminOrderController {
    @Resource
    private OrderService orderService;
    @PostMapping("/page")
    @Operation(summary = "获得充值记录分页")
    @PreAuthorize("@ss.hasPermission('order:page')")
    public CommonResult<PageResult<AdminOrderVo>> getRecordPage(
            @Valid @RequestBody AdminOrderPageVo pageReqVO) {
        PageResult<MemberOrderDo> pageResult = orderService.getRecordPage(pageReqVO);
        return success(BeanUtils.toBean(pageResult, AdminOrderVo.class));
    }
}
